package orthoplanner.com.google.code.utils;

import java.awt.Point;

import processing.core.PVector;

public class TriangleCheck {
	public static boolean check(Point t1, Point t2, Point t3, Point p) {
		boolean ret = false;
		PVector v1 = new PVector(t1.x - p.x, t1.y - p.y).normalize(null);
		PVector v2 = new PVector(t2.x - p.x, t2.y - p.y).normalize(null);
		PVector v3 = new PVector(t3.x - p.x, t3.y - p.y).normalize(null);
		double totalAngle = Math.acos(v1.dot(v2)) + Math.acos(v1.dot(v3))
				+ Math.acos(v2.dot(v3));
		if (Math.abs(totalAngle - (2 * Math.PI)) < 0.1) {
			ret = true;
		}
		return ret;
	}
}
